<?php

/**
 * Description of character
 *
 * @author Christian Simon
 */
class modelCharacter {
    
    public $id;
    public $surname;
    public $lastname;
    public $age;
    public $class;
    public $organisation;
    public $rank;
    public $status;
    public $race;
    public $task;
    public $description;
    public $gender;
    public $profession;
    public $portrait;
    public $relations;
    public $_cid;
    public $_oid;

    public function deserialize($query) {
        $query = (object) $query;
	foreach($query as $field => $value)
	{
	   //if(empty($value))
	       //$query->$field = "null";
	}
        $this->id = $query->_id;
        $this->surname = htmlentities($query->surname, ENT_QUOTES, 'UTF-8');
        $this->lastname = htmlentities($query->lastname, ENT_QUOTES, 'UTF-8');
        $this->age = $query->age;
        $this->class = $query->class;
        $this->organisation = controllerCharacter::getOrganisation($query->_oid);
        $this->rank = controllerCharacter::getRank($query->_rid);
        $this->status = htmlentities($query->status, ENT_QUOTES, 'UTF-8');
        $this->task = htmlentities($query->task, ENT_QUOTES, 'UTF-8');
        $this->description = htmlentities($query->shortdescription, ENT_QUOTES, 'UTF-8');
        $this->gender = $query->gender;
        $this->profession = htmlentities($query->profession);
        $this->portrait = $query->portrait;
        $this->race = $query->race;
        $this->_cid = $query->_cid;
        $this->_oid = $query->_oid;
        //$this->relations = self::getRelations($this->id);
        return $this;
    }
}

?>
